const { util } = require("utils");
const { GXH_MsgType, GXH_Event } = require("../gzhConst");
const { subscribeAction } = require("./subscribe");
const { unsubscribeAction } = require("./unsubscribe");
const { debugDemoAction } = require("./debugDemo");
function dispatch(content, appId, nonce) {
    if (util.nilValue(content) || typeof content !== "object") {
        return "";
    }
    let { xml } = content || {};
    let xmlData = xml || {};
    let { MsgType, Event } = xmlData;
    if (MsgType !== GXH_MsgType) {
        return "";
    }
    // 判断
    if (Event === GXH_Event.debugDemo) {
        return debugDemoAction(xmlData, appId, nonce);
    } else if (Event === GXH_Event.Subscribe) {
        // 订阅
        return subscribeAction(xmlData, appId, nonce);
    } else if (Event === GXH_Event.Unsubscribe) {
        return unsubscribeAction(xmlData, appId, nonce);
    }

    return "";
}

module.exports = {
    dispatch,
};
